package fictional.GUI;

import java.io.IOException;

import org.jdesktop.application.Application;

import fictional.Common.CharacterItem;
import fictional.Common.IBL;
import fictional.Common.Response;

/**
 * This task edits the logged in user's current status.
 */
public class EditStatusTask extends DefaultTask{

	String newStatus;
	CharacterItem character;
	
	public EditStatusTask(Application application) {
		super(application);
	}
	
	public void setTask(IBL BL, GUI gui, String newStatus, CharacterItem character)
	{
		this.BL = BL;
		this.gui = gui;
		this.newStatus = newStatus;
		this.character = character;
	}
	
    @Override
    protected Object doInBackground() throws IOException, InterruptedException
    {
        response = new Response();
        BL.editCharacterStatus(character, newStatus, response);
        
        if (response.isIs_Success())
        {
        	gui.updateStatus(newStatus);
        }
        else
        {
        	errorTitle = "Error Updating Status";
        }
        return null;
    }
}
